/*******************************************************************************
*  file    : deferredresult.cpp
*  created : 29.06.2013
*  author  : 
*******************************************************************************/

#include "deferredresult.hpp"
#include "uzdatagetter.hpp"

#include <qlogger.hpp>

namespace {
QLogger* l_ = QLoggerEngine::getLogger("core");
}

DeferredResult::DeferredResult(QObject *parent) :
    QObject(parent),
    combo_(0)
{
    request_ = "123";
}

void DeferredResult::onCitiesLoaded(const QString& key)
{
    if( key.toUpper() == request_.toUpper())
        emit citiesLoaded();
    else
        logDebug(l_)<<QString("Key not found. %1 != %2").arg(key).arg(request_);
}


TrainDataDeferredResult::TrainDataDeferredResult(UzDataGetter *g, int td_id, QObject *parent) :
    QObject(parent),
    m_trainDataId(td_id)
{
    m_getter = g;
}

void TrainDataDeferredResult::onTrainDataReady(int id)
{
    if( (id == m_trainDataId) && ( !m_getter.isNull()))
        {
            m_result = m_getter->trainData(id);
            emit trainDataReady();
        }
}
